package com.zhangdi.demo.es.thread;

import com.zhangdi.demo.es.entity.CompanyDoc;
import com.zhangdi.demo.es.service.ESUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by zhangdi on 2020/07/10 14:53:40.
 */
@Service
public class ThreadWorker {

    @Autowired
    private ESUserService service;

    @Async("taskExecutor")
    @Transactional(rollbackFor = Exception.class)
    public void run(List<CompanyDoc> companies) {
//        System.out.println("当前运行的线程名称：" + Thread.currentThread().getName());
        service.save(companies);
    }
}
